// Copyright Epic Games, Inc. All Rights Reserved.

#include "CustomSettings/LyraSettingAction_SafeZoneEditor.h"
#include "CustomSettings/LyraSettingValueDiscrete_MobileFPSType.h"
#include "CustomSettings/LyraSettingValueDiscrete_OverallQuality.h"
#include "CustomSettings/LyraSettingValueDiscrete_Resolution.h"
#include "DataSource/GameSettingDataSource.h"
#include "EditCondition/WhenCondition.h"
#include "EditCondition/WhenPlatformHasTrait.h"
#include "EditCondition/WhenPlayingAsPrimaryPlayer.h"
#include "Framework/Application/SlateApplication.h"
#include "GameSettingCollection.h"
#include "GameSettingValueDiscreteDynamic.h"
#include "LyraGameSettingRegistry.h"
#include "LyraSettingsLocal.h"
#include "LyraSettingsShared.h"
#include "NativeGameplayTags.h"
#include "Performance/LyraPerformanceSettings.h"
#include "Player/LyraLocalPlayer.h"

#define LOCTEXT_NAMESPACE "Lyra"

// 定义游戏设置标签
UE_DEFINE_GAMEPLAY_TAG_STATIC(GameSettings_Action_EditSafeZone, "GameSettings.Action.EditSafeZone"); // 编辑安全区域动作标签
UE_DEFINE_GAMEPLAY_TAG_STATIC(GameSettings_Action_EditBrightness, "GameSettings.Action.EditBrightness"); // 编辑亮度动作标签
UE_DEFINE_GAMEPLAY_TAG_STATIC(TAG_Platform_Trait_SupportsWindowedMode, "Platform.Trait.SupportsWindowedMode"); // 支持窗口模式平台特性标签
UE_DEFINE_GAMEPLAY_TAG_STATIC(TAG_Platform_Trait_NeedsBrightnessAdjustment, "Platform.Trait.NeedsBrightnessAdjustment"); // 需要亮度调整平台特性标签

//////////////////////////////////////////////////////////////////////

// 帧步调编辑条件枚举
enum class EFramePacingEditCondition
{
	EnableIf, // 如果满足条件则启用
	DisableIf // 如果满足条件则禁用
};

// 检查平台特定值的帧步调模式编辑条件类
class FGameSettingEditCondition_FramePacingMode : public FGameSettingEditCondition
{
public:
	FGameSettingEditCondition_FramePacingMode(ELyraFramePacingMode InDesiredMode, EFramePacingEditCondition InMatchMode = EFramePacingEditCondition::EnableIf)
		: DesiredMode(InDesiredMode) // 期望模式
		, MatchMode(InMatchMode) // 匹配模式
	{
	}

	/**
	 * 收集编辑状态
	 * @param InLocalPlayer 本地玩家
	 * @param InOutEditState 输入输出编辑状态
	 */
	virtual void GatherEditState(const ULocalPlayer * InLocalPlayer, FGameSettingEditableState & InOutEditState) const override
	{
		const ELyraFramePacingMode ActualMode = ULyraPlatformSpecificRenderingSettings::Get()->FramePacingMode; // 获取实际模式
		
		const bool bMatches = (ActualMode == DesiredMode); // 检查是否匹配
		const bool bMatchesAreBad = (MatchMode == EFramePacingEditCondition::DisableIf); // 检查匹配是否是不好的

		if (bMatches == bMatchesAreBad) // 如果匹配结果与期望相反
		{
			InOutEditState.Kill(FString::Printf(TEXT("Frame pacing mode %d didn't match requirement %d"), (int32)ActualMode, (int32)DesiredMode)); // 禁用设置
		}
	}
private:
	ELyraFramePacingMode DesiredMode; // 期望的帧步调模式
	EFramePacingEditCondition MatchMode; // 匹配模式
};

//////////////////////////////////////////////////////////////////////

// 检查平台特定值的视频质量编辑条件类
class FGameSettingEditCondition_VideoQuality : public FGameSettingEditCondition
{
public:
	FGameSettingEditCondition_VideoQuality(const FString& InDisableString)
		: DisableString(InDisableString) // 禁用字符串
	{
	}

	/**
	 * 收集编辑状态
	 * @param InLocalPlayer 本地玩家
	 * @param InOutEditState 输入输出编辑状态
	 */
	virtual void GatherEditState(const ULocalPlayer* InLocalPlayer, FGameSettingEditableState& InOutEditState) const override
	{
		if (!ULyraPlatformSpecificRenderingSettings::Get()->bSupportsGranularVideoQualitySettings) // 如果不支持细粒度视频质量设置
		{
			InOutEditState.Kill(DisableString); // 禁用设置
		}
	}

	/**
	 * 设置更改时调用
	 * @param LocalPlayer 本地玩家
	 * @param Setting 游戏设置
	 * @param Reason 更改原因
	 */
	virtual void SettingChanged(const ULocalPlayer* LocalPlayer, UGameSetting* Setting, EGameSettingChangeReason Reason) const override
	{
		// TODO 目前这会立即应用设置
		const ULyraLocalPlayer* LyraLocalPlayer = CastChecked<ULyraLocalPlayer>(LocalPlayer); // 转换为Lyra本地玩家
		LyraLocalPlayer->GetLocalSettings()->ApplyScalabilitySettings(); // 应用可伸缩性设置
	}

private:
	FString DisableString; // 禁用字符串
};

////////////////////////////////////////////////////////////////////////////////////

/**
 * 初始化视频设置
 * @param InLocalPlayer 本地玩家
 * @return 游戏设置集合
 */
UGameSettingCollection* ULyraGameSettingRegistry::InitializeVideoSettings(ULyraLocalPlayer* InLocalPlayer)
{
	UGameSettingCollection* Screen = NewObject<UGameSettingCollection>(); // 创建游戏设置集合
	Screen->SetDevName(TEXT("VideoCollection")); // 设置开发名称
	Screen->SetDisplayName(LOCTEXT("VideoCollection_Name", "Video")); // 设置显示名称
	Screen->Initialize(InLocalPlayer); // 初始化

	UGameSettingValueDiscreteDynamic_Enum* WindowModeSetting = nullptr; // 窗口模式设置
	UGameSetting* MobileFPSType = nullptr; // 移动设备FPS类型

	// 显示
	////////////////////////////////////////////////////////////////////////////////////
	{
		UGameSettingCollection* Display = NewObject<UGameSettingCollection>(); // 创建显示设置集合
		Display->SetDevName(TEXT("DisplayCollection")); // 设置开发名称
		Display->SetDisplayName(LOCTEXT("DisplayCollection_Name", "Display")); // 设置显示名称
		Screen->AddSetting(Display); // 添加到屏幕设置

		//----------------------------------------------------------------------------------
		{
			UGameSettingValueDiscreteDynamic_Enum* Setting = NewObject<UGameSettingValueDiscreteDynamic_Enum>(); // 创建枚举离散值设置
			Setting->SetDevName(TEXT("WindowMode")); // 设置开发名称
			Setting->SetDisplayName(LOCTEXT("WindowMode_Name", "Window Mode")); // 设置显示名称
			Setting->SetDescriptionRichText(LOCTEXT("WindowMode_Description", "In Windowed mode you can interact with other windows more easily, and drag the edges of the window to set the size. In Windowed Fullscreen mode you can easily switch between applications. In Fullscreen mode you cannot interact with other windows as easily, but the game will run slightly faster.")); // 设置描述富文本

			Setting->SetDynamicGetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(GetFullscreenMode)); // 设置动态获取器
			Setting->SetDynamicSetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(SetFullscreenMode)); // 设置动态设置器
			Setting->AddEnumOption(EWindowMode::Fullscreen, LOCTEXT("WindowModeFullscreen", "Fullscreen")); // 添加全屏选项
			Setting->AddEnumOption(EWindowMode::WindowedFullscreen, LOCTEXT("WindowModeWindowedFullscreen", "Windowed Fullscreen")); // 添加窗口化全屏选项
			Setting->AddEnumOption(EWindowMode::Windowed, LOCTEXT("WindowModeWindowed", "Windowed")); // 添加窗口化选项

			Setting->AddEditCondition(FWhenPlatformHasTrait::KillIfMissing(TAG_Platform_Trait_SupportsWindowedMode, TEXT("Platform does not support window mode"))); // 添加编辑条件

			WindowModeSetting = Setting; // 保存窗口模式设置引用

			Display->AddSetting(Setting); // 添加到显示设置
		}
		//----------------------------------------------------------------------------------
		{
			ULyraSettingValueDiscrete_Resolution* Setting = NewObject<ULyraSettingValueDiscrete_Resolution>(); // 创建分辨率离散值设置
			Setting->SetDevName(TEXT("Resolution")); // 设置开发名称
			Setting->SetDisplayName(LOCTEXT("Resolution_Name", "Resolution")); // 设置显示名称
			Setting->SetDescriptionRichText(LOCTEXT("Resolution_Description", "Display Resolution determines the size of the window in Windowed mode. In Fullscreen mode, Display Resolution determines the graphics card output resolution, which can result in black bars depending on monitor and graphics card. Display Resolution is inactive in Windowed Fullscreen mode.")); // 设置描述富文本

			Setting->AddEditDependency(WindowModeSetting); // 添加编辑依赖
			Setting->AddEditCondition(FWhenPlatformHasTrait::KillIfMissing(TAG_Platform_Trait_SupportsWindowedMode, TEXT("Platform does not support window mode"))); // 添加编辑条件
			Setting->AddEditCondition(MakeShared<FWhenCondition>([WindowModeSetting](const ULocalPlayer*, FGameSettingEditableState& InOutEditState) // 添加条件检查
			{
				if (WindowModeSetting->GetValue<EWindowMode::Type>() == EWindowMode::WindowedFullscreen) // 如果是窗口化全屏模式
				{
					InOutEditState.Disable(LOCTEXT("ResolutionWindowedFullscreen_Disabled", "When the Window Mode is set to <strong>Windowed Fullscreen</>, the resolution must match the native desktop resolution.")); // 禁用设置
				}
			}));

			Display->AddSetting(Setting); // 添加到显示设置
		}
		//----------------------------------------------------------------------------------
		{
			AddPerformanceStatPage(Display, InLocalPlayer); // 添加性能统计页面
		}
		//----------------------------------------------------------------------------------
	}

	// 图形
	////////////////////////////////////////////////////////////////////////////////////
	{
		UGameSettingCollection* Graphics = NewObject<UGameSettingCollection>(); // 创建图形设置集合
		Graphics->SetDevName(TEXT("GraphicsCollection")); // 设置开发名称
		Graphics->SetDisplayName(LOCTEXT("GraphicsCollection_Name", "Graphics")); // 设置显示名称
		Screen->AddSetting(Graphics); // 添加到屏幕设置

		//----------------------------------------------------------------------------------
		{
			UGameSettingValueDiscreteDynamic_Enum* Setting = NewObject<UGameSettingValueDiscreteDynamic_Enum>(); // 创建枚举离散值设置
			Setting->SetDevName(TEXT("ColorBlindMode")); // 设置开发名称
			Setting->SetDisplayName(LOCTEXT("ColorBlindMode_Name", "Color Blind Mode")); // 设置显示名称
			Setting->SetDescriptionRichText(LOCTEXT("ColorBlindMode_Description", "Using the provided images, test out the different color blind modes to find a color correction that works best for you.")); // 设置描述富文本
			
			Setting->SetDynamicGetter(GET_SHARED_SETTINGS_FUNCTION_PATH(GetColorBlindMode)); // 设置动态获取器
			Setting->SetDynamicSetter(GET_SHARED_SETTINGS_FUNCTION_PATH(SetColorBlindMode)); // 设置动态设置器
			Setting->SetDefaultValue(GetDefault<ULyraSettingsShared>()->GetColorBlindMode()); // 设置默认值
			Setting->AddEnumOption(EColorBlindMode::Off, LOCTEXT("ColorBlindRotatorSettingOff", "Off")); // 添加关闭选项
			Setting->AddEnumOption(EColorBlindMode::Deuteranope, LOCTEXT("ColorBlindRotatorSettingDeuteranope", "Deuteranope")); // 添加绿色弱视选项
			Setting->AddEnumOption(EColorBlindMode::Protanope, LOCTEXT("ColorBlindRotatorSettingProtanope", "Protanope")); // 添加红色弱视选项
			Setting->AddEnumOption(EColorBlindMode::Tritanope, LOCTEXT("ColorBlindRotatorSettingTritanope", "Tritanope")); // 添加蓝色弱视选项

			Setting->AddEditCondition(FWhenPlayingAsPrimaryPlayer::Get()); // 添加编辑条件

			Graphics->AddSetting(Setting); // 添加到图形设置
		}
		//----------------------------------------------------------------------------------
		{
			UGameSettingValueDiscreteDynamic_Number* Setting = NewObject<UGameSettingValueDiscreteDynamic_Number>(); // 创建数字离散值设置
			Setting->SetDevName(TEXT("ColorBlindStrength")); // 设置开发名称
			Setting->SetDisplayName(LOCTEXT("ColorBlindStrength_Name", "Color Blind Strength")); // 设置显示名称
			Setting->SetDescriptionRichText(LOCTEXT("ColorBlindStrength_Description", "Using the provided images, test out the different strengths to find a color correction that works best for you.")); // 设置描述富文本

			Setting->SetDynamicGetter(GET_SHARED_SETTINGS_FUNCTION_PATH(GetColorBlindStrength)); // 设置动态获取器
			Setting->SetDynamicSetter(GET_SHARED_SETTINGS_FUNCTION_PATH(SetColorBlindStrength)); // 设置动态设置器
			Setting->SetDefaultValue(GetDefault<ULyraSettingsShared>()->GetColorBlindStrength()); // 设置默认值
			for (int32 Index = 0; Index <= 10; Index++) // 遍历0-10
			{
				Setting->AddOption(Index, FText::AsNumber(Index)); // 添加选项
			}

			Setting->AddEditCondition(FWhenPlayingAsPrimaryPlayer::Get()); // 添加编辑条件

			Graphics->AddSetting(Setting); // 添加到图形设置
		}
		//----------------------------------------------------------------------------------
		{
			UGameSettingValueScalarDynamic* Setting = NewObject<UGameSettingValueScalarDynamic>(); // 创建标量动态值设置
			Setting->SetDevName(TEXT("Brightness")); // 设置开发名称
			Setting->SetDisplayName(LOCTEXT("Brightness_Name", "Brightness")); // 设置显示名称
			Setting->SetDescriptionRichText(LOCTEXT("Brightness_Description", "Adjusts the brightness.")); // 设置描述富文本

			Setting->SetDynamicGetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(GetDisplayGamma)); // 设置动态获取器
			Setting->SetDynamicSetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(SetDisplayGamma)); // 设置动态设置器
			Setting->SetDefaultValue(2.2); // 设置默认值
			Setting->SetDisplayFormat([](double SourceValue, double NormalizedValue) { // 设置显示格式
				return FText::Format(LOCTEXT("BrightnessFormat", "{0}%"), (int32)FMath::GetMappedRangeValueClamped(FVector2D(0, 1), FVector2D(50, 150), NormalizedValue)); // 返回格式化文本
			});
			Setting->SetSourceRangeAndStep(TRange<double>(1.7, 2.7), 0.01); // 设置源范围和步长

			Setting->AddEditCondition(FWhenPlayingAsPrimaryPlayer::Get()); // 添加编辑条件
			Setting->AddEditCondition(FWhenPlatformHasTrait::KillIfMissing(TAG_Platform_Trait_NeedsBrightnessAdjustment, TEXT("Platform does not require brightness adjustment."))); // 添加编辑条件

			Graphics->AddSetting(Setting); // 添加到图形设置
		}
		//----------------------------------------------------------------------------------
		{
			ULyraSettingAction_SafeZoneEditor* Setting = NewObject<ULyraSettingAction_SafeZoneEditor>(); // 创建安全区域编辑器动作设置
			Setting->SetDevName(TEXT("SafeZone")); // 设置开发名称
			Setting->SetDisplayName(LOCTEXT("SafeZone_Name", "Safe Zone")); // 设置显示名称
			Setting->SetDescriptionRichText(LOCTEXT("SafeZone_Description", "Set the UI safe zone for the platform.")); // 设置描述富文本
			Setting->SetActionText(LOCTEXT("SafeZone_Action", "Set Safe Zone")); // 设置动作文本
			Setting->SetNamedAction(GameSettings_Action_EditSafeZone); // 设置命名动作

			Setting->AddEditCondition(FWhenPlayingAsPrimaryPlayer::Get()); // 添加编辑条件
			Setting->AddEditCondition(MakeShared<FWhenCondition>([](const ULocalPlayer*, FGameSettingEditableState& InOutEditState) { // 添加条件检查
				FDisplayMetrics Metrics; // 显示指标
				FSlateApplication::Get().GetCachedDisplayMetrics(Metrics); // 获取缓存的显示指标
				if (Metrics.TitleSafePaddingSize.Size() == 0) // 如果标题安全填充大小为0
				{
					InOutEditState.Kill(TEXT("Platform does not have any TitleSafePaddingSize configured in the display metrics.")); // 禁用设置
				}
			}));

			Graphics->AddSetting(Setting); // 添加到图形设置
		}
		//----------------------------------------------------------------------------------
	}


	// 图形质量
	////////////////////////////////////////////////////////////////////////////////////
	{
		UGameSettingCollection* GraphicsQuality = NewObject<UGameSettingCollection>(); // 创建图形质量设置集合
		GraphicsQuality->SetDevName(TEXT("GraphicsQuality")); // 设置开发名称
		GraphicsQuality->SetDisplayName(LOCTEXT("GraphicsQuality_Name", "Graphics Quality")); // 设置显示名称
		Screen->AddSetting(GraphicsQuality); // 添加到屏幕设置

		UGameSetting* AutoSetQuality = nullptr; // 自动设置质量
		UGameSetting* GraphicsQualityPresets = nullptr; // 图形质量预设

		//----------------------------------------------------------------------------------
		{
			// 控制台风格的设备配置文件选择
			UGameSettingValueDiscreteDynamic* Setting = NewObject<UGameSettingValueDiscreteDynamic>(); // 创建离散动态值设置
			Setting->SetDevName(TEXT("DeviceProfileSuffix")); // 设置开发名称
			Setting->SetDisplayName(LOCTEXT("DeviceProfileSuffix_Name", "Quality Presets")); // 设置显示名称
			Setting->SetDescriptionRichText(LOCTEXT("DeviceProfileSuffix_Description", "Choose between different quality presets to make a trade off between quality and speed.")); // 设置描述富文本
			Setting->SetDynamicGetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(GetDesiredDeviceProfileQualitySuffix)); // 设置动态获取器
			Setting->SetDynamicSetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(SetDesiredDeviceProfileQualitySuffix)); // 设置动态设置器

			const ULyraPlatformSpecificRenderingSettings* PlatformSettings = ULyraPlatformSpecificRenderingSettings::Get(); // 获取平台特定渲染设置

			Setting->SetDefaultValueFromString(PlatformSettings->DefaultDeviceProfileSuffix); // 设置默认值
			for (const FLyraQualityDeviceProfileVariant& Variant : PlatformSettings->UserFacingDeviceProfileOptions) // 遍历面向用户的设备配置文件变体
			{
				if (FPlatformMisc::GetMaxRefreshRate() >= Variant.MinRefreshRate) // 如果平台最大刷新率大于等于最小刷新率
				{
					Setting->AddDynamicOption(Variant.DeviceProfileSuffix, Variant.DisplayName); // 添加动态选项
				}
			}

			if (Setting->GetDynamicOptions().Num() > 1) // 如果动态选项数量大于1
			{
				GraphicsQuality->AddSetting(Setting); // 添加到图形质量设置
			}
		}

		//----------------------------------------------------------------------------------
		{
			// 移动设备风格的帧率选择
			ULyraSettingValueDiscrete_MobileFPSType* Setting = NewObject<ULyraSettingValueDiscrete_MobileFPSType>(); // 创建移动设备FPS类型离散值设置
			MobileFPSType = Setting; // 保存移动设备FPS类型引用

			Setting->SetDevName(TEXT("FrameRateLimit_Mobile")); // 设置开发名称
			Setting->SetDisplayName(LOCTEXT("FrameRateLimit_Mobile_Name", "Frame Rate Limit")); // 设置显示名称
			Setting->SetDescriptionRichText(LOCTEXT("FrameRateLimit_Mobile_Description", "Select a desired framerate. Use this to fine tune performance on your device.")); // 设置描述富文本

			Setting->AddEditCondition(MakeShared<FGameSettingEditCondition_FramePacingMode>(ELyraFramePacingMode::MobileStyle)); // 添加编辑条件

			GraphicsQuality->AddSetting(Setting); // 添加到图形质量设置
		}

		//----------------------------------------------------------------------------------
		{
			UGameSettingAction* Setting = NewObject<UGameSettingAction>(); // 创建游戏设置动作
			Setting->SetDevName(TEXT("AutoSetQuality")); // 设置开发名称
			Setting->SetDisplayName(LOCTEXT("AutoSetQuality_Name", "Auto-Set Quality")); // 设置显示名称
			Setting->SetDescriptionRichText(LOCTEXT("AutoSetQuality_Description", "Automatically configure the graphics quality options based on a benchmark of the hardware.")); // 设置描述富文本

			Setting->SetDoesActionDirtySettings(true); // 设置动作是否会弄脏设置
			Setting->SetActionText(LOCTEXT("AutoSetQuality_Action", "Auto-Set")); // 设置动作文本
			Setting->SetCustomAction([](ULocalPlayer* LocalPlayer) // 设置自定义动作
			{
				const ULyraPlatformSpecificRenderingSettings* PlatformSettings = ULyraPlatformSpecificRenderingSettings::Get(); // 获取平台特定渲染设置
				if (PlatformSettings->FramePacingMode == ELyraFramePacingMode::MobileStyle) // 如果是移动设备风格帧步调
				{
					ULyraSettingsLocal::Get()->ResetToMobileDeviceDefaults(); // 重置为移动设备默认值
				}
				else
				{
					const ULyraLocalPlayer* LyraLocalPlayer = CastChecked<ULyraLocalPlayer>(LocalPlayer); // 转换为Lyra本地玩家
					// 我们不保存状态，直到用户应用设置
					constexpr bool bImmediatelySaveState = false; // 不立即保存状态
					LyraLocalPlayer->GetLocalSettings()->RunAutoBenchmark(bImmediatelySaveState); // 运行自动基准测试
				}
			});

			Setting->AddEditCondition(MakeShared<FWhenCondition>([](const ULocalPlayer* LocalPlayer, FGameSettingEditableState& InOutEditState) // 添加条件检查
			{
				const ULyraPlatformSpecificRenderingSettings* PlatformSettings = ULyraPlatformSpecificRenderingSettings::Get(); // 获取平台特定渲染设置
				const bool bCanUseDueToMobile = (PlatformSettings->FramePacingMode == ELyraFramePacingMode::MobileStyle); // 检查是否由于移动设备而可以使用

				const ULyraLocalPlayer* LyraLocalPlayer = CastChecked<ULyraLocalPlayer>(LocalPlayer); // 转换为Lyra本地玩家
				const bool bCanBenchmark = LyraLocalPlayer->GetLocalSettings()->CanRunAutoBenchmark(); // 检查是否可以运行基准测试

				if (!bCanUseDueToMobile && !bCanBenchmark) // 如果既不能由于移动设备使用也不能运行基准测试
				{
					InOutEditState.Kill(TEXT("Auto quality not supported")); // 禁用设置
				}
			}));

			if (MobileFPSType != nullptr) // 如果移动设备FPS类型存在
			{
				MobileFPSType->AddEditDependency(Setting); // 添加编辑依赖
			}

			GraphicsQuality->AddSetting(Setting); // 添加到图形质量设置

			AutoSetQuality = Setting; // 保存自动设置质量引用
		}
		//----------------------------------------------------------------------------------
		{
			ULyraSettingValueDiscrete_OverallQuality* Setting = NewObject<ULyraSettingValueDiscrete_OverallQuality>(); // 创建整体质量离散值设置
			Setting->SetDevName(TEXT("GraphicsQualityPresets")); // 设置开发名称
			Setting->SetDisplayName(LOCTEXT("GraphicsQualityPresets_Name", "Quality Presets")); // 设置显示名称
			Setting->SetDescriptionRichText(LOCTEXT("GraphicsQualityPresets_Description", "Quality Preset allows you to adjust multiple video options at once. Try a few options to see what fits your preference and device's performance.")); // 设置描述富文本

			Setting->AddEditDependency(AutoSetQuality); // 添加编辑依赖

			Setting->AddEditCondition(MakeShared<FGameSettingEditCondition_FramePacingMode>(ELyraFramePacingMode::ConsoleStyle, EFramePacingEditCondition::DisableIf)); // 添加编辑条件

			if (MobileFPSType != nullptr) // 如果移动设备FPS类型存在
			{
				Setting->AddEditDependency(MobileFPSType); // 添加编辑依赖
				MobileFPSType->AddEditDependency(Setting); // 添加编辑依赖
			}

			GraphicsQuality->AddSetting(Setting); // 添加到图形质量设置

			GraphicsQualityPresets = Setting; // 保存图形质量预设引用
		}
		//----------------------------------------------------------------------------------
		{
			UGameSettingValueScalarDynamic* Setting = NewObject<UGameSettingValueScalarDynamic>(); // 创建标量动态值设置
			Setting->SetDevName(TEXT("ResolutionScale")); // 设置开发名称
			Setting->SetDisplayName(LOCTEXT("ResolutionScale_Name", "3D Resolution")); // 设置显示名称
			Setting->SetDescriptionRichText(LOCTEXT("ResolutionScale_Description", "3D resolution determines the resolution that objects are rendered in game, but does not affect the main menu.  Lower resolutions can significantly increase frame rate.")); // 设置描述富文本

			Setting->SetDynamicGetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(GetResolutionScaleNormalized)); // 设置动态获取器
			Setting->SetDynamicSetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(SetResolutionScaleNormalized)); // 设置动态设置器
			Setting->SetDisplayFormat(UGameSettingValueScalarDynamic::ZeroToOnePercent); // 设置显示格式

			Setting->AddEditDependency(AutoSetQuality); // 添加编辑依赖
			Setting->AddEditDependency(GraphicsQualityPresets); // 添加编辑依赖
			Setting->AddEditCondition(MakeShared<FGameSettingEditCondition_VideoQuality>(TEXT("Platform does not support 3D Resolution"))); // 添加编辑条件
			//@TODO: 为移动设备添加3D分辨率支持

			// 当此设置更改时，它可以将GraphicsQualityPresets设置为自定义或特定预设
			GraphicsQualityPresets->AddEditDependency(Setting); // 添加编辑依赖
			GraphicsQuality->AddSetting(Setting); // 添加到图形质量设置
		}
		//----------------------------------------------------------------------------------
		{
			UGameSettingValueDiscreteDynamic_Number* Setting = NewObject<UGameSettingValueDiscreteDynamic_Number>(); // 创建数字离散值设置
			Setting->SetDevName(TEXT("GlobalIlluminationQuality")); // 设置开发名称
			Setting->SetDisplayName(LOCTEXT("GlobalIlluminationQuality_Name", "Global Illumination")); // 设置显示名称
			Setting->SetDescriptionRichText(LOCTEXT("GlobalIlluminationQuality_Description", "Global Illumination controls the quality of dynamically calculated indirect lighting bounces, sky shadowing and Ambient Occlusion. Settings of 'High' and above use more accurate ray tracing methods to solve lighting, but can reduce performance.")); // 设置描述富文本

			Setting->SetDynamicGetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(GetGlobalIlluminationQuality)); // 设置动态获取器
			Setting->SetDynamicSetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(SetGlobalIlluminationQuality)); // 设置动态设置器
			Setting->AddOption(0, LOCTEXT("VisualEffectQualityLow", "Low")); // 添加低质量选项
			Setting->AddOption(1, LOCTEXT("VisualEffectQualityMedium", "Medium")); // 添加中等质量选项
			Setting->AddOption(2, LOCTEXT("VisualEffectQualityHigh", "High")); // 添加高质量选项
			Setting->AddOption(3, LOCTEXT("VisualEffectQualityEpic", "Epic")); // 添加史诗质量选项

			Setting->AddEditDependency(AutoSetQuality); // 添加编辑依赖
			Setting->AddEditDependency(GraphicsQualityPresets); // 添加编辑依赖
			Setting->AddEditCondition(MakeShared<FGameSettingEditCondition_VideoQuality>(TEXT("Platform does not support GlobalIlluminationQuality"))); // 添加编辑条件

			// 当此设置更改时，它可以将GraphicsQualityPresets设置为自定义或特定预设
			GraphicsQualityPresets->AddEditDependency(Setting); // 添加编辑依赖

			GraphicsQuality->AddSetting(Setting); // 添加到图形质量设置
		}
		//----------------------------------------------------------------------------------
		{
			UGameSettingValueDiscreteDynamic_Number* Setting = NewObject<UGameSettingValueDiscreteDynamic_Number>(); // 创建数字离散值设置
			Setting->SetDevName(TEXT("Shadows")); // 设置开发名称
			Setting->SetDisplayName(LOCTEXT("Shadows_Name", "Shadows")); // 设置显示名称
			Setting->SetDescriptionRichText(LOCTEXT("Shadows_Description", "Shadow quality determines the resolution and view distance of dynamic shadows. Shadows improve visual quality and give better depth perception, but can reduce performance.")); // 设置描述富文本

			Setting->SetDynamicGetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(GetShadowQuality)); // 设置动态获取器
			Setting->SetDynamicSetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(SetShadowQuality)); // 设置动态设置器
			Setting->AddOption(0, LOCTEXT("ShadowLow", "Off")); // 添加关闭选项
			Setting->AddOption(1, LOCTEXT("ShadowMedium", "Medium")); // 添加中等选项
			Setting->AddOption(2, LOCTEXT("ShadowHigh", "High")); // 添加高选项
			Setting->AddOption(3, LOCTEXT("ShadowEpic", "Epic")); // 添加史诗选项

			Setting->AddEditDependency(AutoSetQuality); // 添加编辑依赖
			Setting->AddEditDependency(GraphicsQualityPresets); // 添加编辑依赖
			Setting->AddEditCondition(MakeShared<FGameSettingEditCondition_VideoQuality>(TEXT("Platform does not support Shadows"))); // 添加编辑条件

			// 当此设置更改时，它可以将GraphicsQualityPresets设置为自定义或特定预设
			GraphicsQualityPresets->AddEditDependency(Setting); // 添加编辑依赖

			GraphicsQuality->AddSetting(Setting); // 添加到图形质量设置
		}
		//----------------------------------------------------------------------------------
		{
			UGameSettingValueDiscreteDynamic_Number* Setting = NewObject<UGameSettingValueDiscreteDynamic_Number>(); // 创建数字离散值设置
			Setting->SetDevName(TEXT("AntiAliasing")); // 设置开发名称
			Setting->SetDisplayName(LOCTEXT("AntiAliasing_Name", "Anti-Aliasing")); // 设置显示名称
			Setting->SetDescriptionRichText(LOCTEXT("AntiAliasing_Description", "Anti-Aliasing reduces jaggy artifacts along geometry edges. Increasing this setting will make edges look smoother, but can reduce performance. Higher settings mean more anti-aliasing.")); // 设置描述富文本

			Setting->SetDynamicGetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(GetAntiAliasingQuality)); // 设置动态获取器
			Setting->SetDynamicSetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(SetAntiAliasingQuality)); // 设置动态设置器
			Setting->AddOption(0, LOCTEXT("AntiAliasingLow", "Off")); // 添加关闭选项
			Setting->AddOption(1, LOCTEXT("AntiAliasingMedium", "Medium")); // 添加中等选项
			Setting->AddOption(2, LOCTEXT("AntiAliasingHigh", "High")); // 添加高选项
			Setting->AddOption(3, LOCTEXT("AntiAliasingEpic", "Epic")); // 添加史诗选项

			Setting->AddEditDependency(AutoSetQuality); // 添加编辑依赖
			Setting->AddEditDependency(GraphicsQualityPresets); // 添加编辑依赖
			Setting->AddEditCondition(MakeShared<FGameSettingEditCondition_VideoQuality>(TEXT("Platform does not support Anti-Aliasing"))); // 添加编辑条件

			// 当此设置更改时，它可以将GraphicsQualityPresets设置为自定义或特定预设
			GraphicsQualityPresets->AddEditDependency(Setting); // 添加编辑依赖

			GraphicsQuality->AddSetting(Setting); // 添加到图形质量设置
		}
		//----------------------------------------------------------------------------------
		{
			UGameSettingValueDiscreteDynamic_Number* Setting = NewObject<UGameSettingValueDiscreteDynamic_Number>(); // 创建数字离散值设置
			Setting->SetDevName(TEXT("ViewDistance")); // 设置开发名称
			Setting->SetDisplayName(LOCTEXT("ViewDistance_Name", "View Distance")); // 设置显示名称
			Setting->SetDescriptionRichText(LOCTEXT("ViewDistance_Description", "View distance determines how far away objects are culled for performance.")); // 设置描述富文本

			Setting->SetDynamicGetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(GetViewDistanceQuality)); // 设置动态获取器
			Setting->SetDynamicSetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(SetViewDistanceQuality)); // 设置动态设置器
			Setting->AddOption(0, LOCTEXT("ViewDistanceNear", "Near")); // 添加近选项
			Setting->AddOption(1, LOCTEXT("ViewDistanceMedium", "Medium")); // 添加中等选项
			Setting->AddOption(2, LOCTEXT("ViewDistanceFar", "Far")); // 添加远选项
			Setting->AddOption(3, LOCTEXT("ViewDistanceEpic", "Epic")); // 添加史诗选项

			Setting->AddEditDependency(AutoSetQuality); // 添加编辑依赖
			Setting->AddEditDependency(GraphicsQualityPresets); // 添加编辑依赖
			Setting->AddEditCondition(MakeShared<FGameSettingEditCondition_VideoQuality>(TEXT("Platform does not support View Distance"))); // 添加编辑条件

			// 当此设置更改时，它可以将GraphicsQualityPresets设置为自定义或特定预设
			GraphicsQualityPresets->AddEditDependency(Setting); // 添加编辑依赖

			GraphicsQuality->AddSetting(Setting); // 添加到图形质量设置
		}
		//----------------------------------------------------------------------------------
		{
			UGameSettingValueDiscreteDynamic_Number* Setting = NewObject<UGameSettingValueDiscreteDynamic_Number>(); // 创建数字离散值设置
			Setting->SetDevName(TEXT("TextureQuality")); // 设置开发名称
			Setting->SetDisplayName(LOCTEXT("TextureQuality_Name", "Textures")); // 设置显示名称

			Setting->SetDescriptionRichText(LOCTEXT("TextureQuality_Description", "Texture quality determines the resolution of textures in game. Increasing this setting will make objects more detailed, but can reduce performance.")); // 设置描述富文本

			Setting->SetDynamicGetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(GetTextureQuality)); // 设置动态获取器
			Setting->SetDynamicSetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(SetTextureQuality)); // 设置动态设置器
			Setting->AddOption(0, LOCTEXT("TextureQualityLow", "Low")); // 添加低质量选项
			Setting->AddOption(1, LOCTEXT("TextureQualityMedium", "Medium")); // 添加中等质量选项
			Setting->AddOption(2, LOCTEXT("TextureQualityHigh", "High")); // 添加高质量选项
			Setting->AddOption(3, LOCTEXT("TextureQualityEpic", "Epic")); // 添加史诗质量选项

			Setting->AddEditDependency(AutoSetQuality); // 添加编辑依赖
			Setting->AddEditDependency(GraphicsQualityPresets); // 添加编辑依赖
			Setting->AddEditCondition(MakeShared<FGameSettingEditCondition_VideoQuality>(TEXT("Platform does not support Texture quality"))); // 添加编辑条件

			// 当此设置更改时，它可以将GraphicsQualityPresets设置为自定义或特定预设
			GraphicsQualityPresets->AddEditDependency(Setting); // 添加编辑依赖

			GraphicsQuality->AddSetting(Setting); // 添加到图形质量设置
		}
		//----------------------------------------------------------------------------------
		{
			UGameSettingValueDiscreteDynamic_Number* Setting = NewObject<UGameSettingValueDiscreteDynamic_Number>(); // 创建数字离散值设置
			Setting->SetDevName(TEXT("VisualEffectQuality")); // 设置开发名称
			Setting->SetDisplayName(LOCTEXT("VisualEffectQuality_Name", "Effects")); // 设置显示名称
			Setting->SetDescriptionRichText(LOCTEXT("VisualEffectQuality_Description", "Effects determines the quality of visual effects and lighting in game. Increasing this setting will increase the quality of visual effects, but can reduce performance.")); // 设置描述富文本

			Setting->SetDynamicGetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(GetVisualEffectQuality)); // 设置动态获取器
			Setting->SetDynamicSetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(SetVisualEffectQuality)); // 设置动态设置器
			Setting->AddOption(0, LOCTEXT("VisualEffectQualityLow", "Low")); // 添加低质量选项
			Setting->AddOption(1, LOCTEXT("VisualEffectQualityMedium", "Medium")); // 添加中等质量选项
			Setting->AddOption(2, LOCTEXT("VisualEffectQualityHigh", "High")); // 添加高质量选项
			Setting->AddOption(3, LOCTEXT("VisualEffectQualityEpic", "Epic")); // 添加史诗质量选项

			Setting->AddEditDependency(AutoSetQuality); // 添加编辑依赖
			Setting->AddEditDependency(GraphicsQualityPresets); // 添加编辑依赖
			Setting->AddEditCondition(MakeShared<FGameSettingEditCondition_VideoQuality>(TEXT("Platform does not support VisualEffectQuality"))); // 添加编辑条件

			// 当此设置更改时，它可以将GraphicsQualityPresets设置为自定义或特定预设
			GraphicsQualityPresets->AddEditDependency(Setting); // 添加编辑依赖

			GraphicsQuality->AddSetting(Setting); // 添加到图形质量设置
		}
		//----------------------------------------------------------------------------------
		{
			UGameSettingValueDiscreteDynamic_Number* Setting = NewObject<UGameSettingValueDiscreteDynamic_Number>(); // 创建数字离散值设置
			Setting->SetDevName(TEXT("ReflectionQuality")); // 设置开发名称
			Setting->SetDisplayName(LOCTEXT("ReflectionQuality_Name", "Reflections")); // 设置显示名称
			Setting->SetDescriptionRichText(LOCTEXT("ReflectionQuality_Description", "Reflection quality determines the resolution and accuracy of reflections.  Settings of 'High' and above use more accurate ray tracing methods to solve reflections, but can reduce performance.")); // 设置描述富文本

			Setting->SetDynamicGetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(GetReflectionQuality)); // 设置动态获取器
			Setting->SetDynamicSetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(SetReflectionQuality)); // 设置动态设置器
			Setting->AddOption(0, LOCTEXT("VisualEffectQualityLow", "Low")); // 添加低质量选项
			Setting->AddOption(1, LOCTEXT("VisualEffectQualityMedium", "Medium")); // 添加中等质量选项
			Setting->AddOption(2, LOCTEXT("VisualEffectQualityHigh", "High")); // 添加高质量选项
			Setting->AddOption(3, LOCTEXT("VisualEffectQualityEpic", "Epic")); // 添加史诗质量选项

			Setting->AddEditDependency(AutoSetQuality); // 添加编辑依赖
			Setting->AddEditDependency(GraphicsQualityPresets); // 添加编辑依赖
			Setting->AddEditCondition(MakeShared<FGameSettingEditCondition_VideoQuality>(TEXT("Platform does not support ReflectionQuality"))); // 添加编辑条件

			// 当此设置更改时，它可以将GraphicsQualityPresets设置为自定义或特定预设
			GraphicsQualityPresets->AddEditDependency(Setting); // 添加编辑依赖

			GraphicsQuality->AddSetting(Setting); // 添加到图形质量设置
		}
		//----------------------------------------------------------------------------------
		{
			UGameSettingValueDiscreteDynamic_Number* Setting = NewObject<UGameSettingValueDiscreteDynamic_Number>(); // 创建数字离散值设置
			Setting->SetDevName(TEXT("PostProcessingQuality")); // 设置开发名称
			Setting->SetDisplayName(LOCTEXT("PostProcessingQuality_Name", "Post Processing")); // 设置显示名称
			Setting->SetDescriptionRichText(LOCTEXT("PostProcessingQuality_Description", "Post Processing effects include Motion Blur, Depth of Field and Bloom. Increasing this setting improves the quality of post process effects, but can reduce performance."));  // 设置描述富文本

			Setting->SetDynamicGetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(GetPostProcessingQuality)); // 设置动态获取器
			Setting->SetDynamicSetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(SetPostProcessingQuality)); // 设置动态设置器
			Setting->AddOption(0, LOCTEXT("PostProcessingQualityLow", "Low")); // 添加低质量选项
			Setting->AddOption(1, LOCTEXT("PostProcessingQualityMedium", "Medium")); // 添加中等质量选项
			Setting->AddOption(2, LOCTEXT("PostProcessingQualityHigh", "High")); // 添加高质量选项
			Setting->AddOption(3, LOCTEXT("PostProcessingQualityEpic", "Epic")); // 添加史诗质量选项

			Setting->AddEditDependency(AutoSetQuality); // 添加编辑依赖
			Setting->AddEditDependency(GraphicsQualityPresets); // 添加编辑依赖
			Setting->AddEditCondition(MakeShared<FGameSettingEditCondition_VideoQuality>(TEXT("Platform does not support PostProcessingQuality"))); // 添加编辑条件

			// 当此设置更改时，它可以将GraphicsQualityPresets设置为自定义或特定预设
			GraphicsQualityPresets->AddEditDependency(Setting); // 添加编辑依赖

			GraphicsQuality->AddSetting(Setting); // 添加到图形质量设置
		}

	}

	// 高级图形
	////////////////////////////////////////////////////////////////////////////////////
	{
		UGameSettingCollection* AdvancedGraphics = NewObject<UGameSettingCollection>(); // 创建高级图形设置集合
		AdvancedGraphics->SetDevName(TEXT("AdvancedGraphics")); // 设置开发名称
		AdvancedGraphics->SetDisplayName(LOCTEXT("AdvancedGraphics_Name", "Advanced Graphics")); // 设置显示名称
		Screen->AddSetting(AdvancedGraphics); // 添加到屏幕设置

		//----------------------------------------------------------------------------------
		{
			UGameSettingValueDiscreteDynamic_Bool* Setting = NewObject<UGameSettingValueDiscreteDynamic_Bool>(); // 创建布尔离散值设置
			Setting->SetDevName(TEXT("VerticalSync")); // 设置开发名称
			Setting->SetDisplayName(LOCTEXT("VerticalSync_Name", "Vertical Sync")); // 设置显示名称
			Setting->SetDescriptionRichText(LOCTEXT("VerticalSync_Description", "Enabling Vertical Sync eliminates screen tearing by always rendering and presenting a full frame. Disabling Vertical Sync can give higher frame rate and better input response, but can result in horizontal screen tearing.")); // 设置描述富文本

			Setting->SetDynamicGetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(IsVSyncEnabled)); // 设置动态获取器
			Setting->SetDynamicSetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(SetVSyncEnabled)); // 设置动态设置器
			Setting->SetDefaultValue(false); // 设置默认值

			Setting->AddEditCondition(MakeShared<FGameSettingEditCondition_FramePacingMode>(ELyraFramePacingMode::DesktopStyle)); // 添加编辑条件

			Setting->AddEditDependency(WindowModeSetting); // 添加编辑依赖
			Setting->AddEditCondition(MakeShared<FWhenCondition>([WindowModeSetting](const ULocalPlayer*, FGameSettingEditableState& InOutEditState) { // 添加条件检查
				if (WindowModeSetting->GetValue<EWindowMode::Type>() != EWindowMode::Fullscreen) // 如果不是全屏模式
				{
					InOutEditState.Disable(LOCTEXT("FullscreenNeededForVSync", "This feature only works if 'Window Mode' is set to 'Fullscreen'.")); // 禁用设置
				}
			}));

			AdvancedGraphics->AddSetting(Setting); // 添加到高级图形设置
		}
	}

	return Screen; // 返回屏幕设置集合
}

/**
 * 添加帧率选项
 * @param Setting 设置对象
 */
void AddFrameRateOptions(UGameSettingValueDiscreteDynamic_Number* Setting)
{
	const FText FPSFormat = LOCTEXT("FPSFormat", "{0} FPS"); // FPS格式文本
	for (int32 Rate : GetDefault<ULyraPerformanceSettings>()->DesktopFrameRateLimits) // 遍历桌面帧率限制
	{
		Setting->AddOption((float)Rate, FText::Format(FPSFormat, Rate)); // 添加选项
	}
	Setting->AddOption(0.0f, LOCTEXT("UnlimitedFPS", "Unlimited")); // 添加无限制选项
}

/**
 * 初始化视频设置-帧率
 * @param Screen 游戏设置集合
 * @param InLocalPlayer 本地玩家
 */
void ULyraGameSettingRegistry::InitializeVideoSettings_FrameRates(UGameSettingCollection* Screen, ULyraLocalPlayer* InLocalPlayer)
{
	//----------------------------------------------------------------------------------
	{
		UGameSettingValueDiscreteDynamic_Number* Setting = NewObject<UGameSettingValueDiscreteDynamic_Number>(); // 创建数字离散值设置
		Setting->SetDevName(TEXT("FrameRateLimit_OnBattery")); // 设置开发名称
		Setting->SetDisplayName(LOCTEXT("FrameRateLimit_OnBattery_Name", "Frame Rate Limit (On Battery)")); // 设置显示名称
		Setting->SetDescriptionRichText(LOCTEXT("FrameRateLimit_OnBattery_Description", "Frame rate limit when running on battery. Set this lower for a more consistent frame rate or higher for the best experience on faster machines. You may need to disable Vsync to reach high frame rates.")); // 设置描述富文本

		Setting->SetDynamicGetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(GetFrameRateLimit_OnBattery)); // 设置动态获取器
		Setting->SetDynamicSetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(SetFrameRateLimit_OnBattery)); // 设置动态设置器
		Setting->SetDefaultValue(GetDefault<ULyraSettingsLocal>()->GetFrameRateLimit_OnBattery()); // 设置默认值

		Setting->AddEditCondition(MakeShared<FGameSettingEditCondition_FramePacingMode>(ELyraFramePacingMode::DesktopStyle)); // 添加编辑条件
		//@TODO: 如果此设备没有电池则隐藏（目前没有此API）

		AddFrameRateOptions(Setting); // 添加帧率选项

		Screen->AddSetting(Setting); // 添加到屏幕设置
	}
	//----------------------------------------------------------------------------------
	{
		UGameSettingValueDiscreteDynamic_Number* Setting = NewObject<UGameSettingValueDiscreteDynamic_Number>(); // 创建数字离散值设置
		Setting->SetDevName(TEXT("FrameRateLimit_InMenu")); // 设置开发名称
		Setting->SetDisplayName(LOCTEXT("FrameRateLimit_InMenu_Name", "Frame Rate Limit (Menu)")); // 设置显示名称
		Setting->SetDescriptionRichText(LOCTEXT("FrameRateLimit_InMenu_Description", "Frame rate limit when in the menu. Set this lower for a more consistent frame rate or higher for the best experience on faster machines. You may need to disable Vsync to reach high frame rates.")); // 设置描述富文本

		Setting->SetDynamicGetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(GetFrameRateLimit_InMenu)); // 设置动态获取器
		Setting->SetDynamicSetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(SetFrameRateLimit_InMenu)); // 设置动态设置器
		Setting->SetDefaultValue(GetDefault<ULyraSettingsLocal>()->GetFrameRateLimit_InMenu()); // 设置默认值
		Setting->AddEditCondition(MakeShared<FGameSettingEditCondition_FramePacingMode>(ELyraFramePacingMode::DesktopStyle)); // 添加编辑条件

		AddFrameRateOptions(Setting); // 添加帧率选项

		Screen->AddSetting(Setting); // 添加到屏幕设置
	}
	//----------------------------------------------------------------------------------
	{
		UGameSettingValueDiscreteDynamic_Number* Setting = NewObject<UGameSettingValueDiscreteDynamic_Number>(); // 创建数字离散值设置
		Setting->SetDevName(TEXT("FrameRateLimit_WhenBackgrounded")); // 设置开发名称
		Setting->SetDisplayName(LOCTEXT("FrameRateLimit_WhenBackgrounded_Name", "Frame Rate Limit (Background)")); // 设置显示名称
		Setting->SetDescriptionRichText(LOCTEXT("FrameRateLimit_WhenBackgrounded_Description", "Frame rate limit when in the background. Set this lower for a more consistent frame rate or higher for the best experience on faster machines. You may need to disable Vsync to reach high frame rates.")); // 设置描述富文本

		Setting->SetDynamicGetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(GetFrameRateLimit_WhenBackgrounded)); // 设置动态获取器
		Setting->SetDynamicSetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(SetFrameRateLimit_WhenBackgrounded)); // 设置动态设置器
		Setting->SetDefaultValue(GetDefault<ULyraSettingsLocal>()->GetFrameRateLimit_WhenBackgrounded()); // 设置默认值
		Setting->AddEditCondition(MakeShared<FGameSettingEditCondition_FramePacingMode>(ELyraFramePacingMode::DesktopStyle)); // 添加编辑条件

		AddFrameRateOptions(Setting); // 添加帧率选项

		Screen->AddSetting(Setting); // 添加到屏幕设置
	}
	//----------------------------------------------------------------------------------
	{
		UGameSettingValueDiscreteDynamic_Number* Setting = NewObject<UGameSettingValueDiscreteDynamic_Number>(); // 创建数字离散值设置
		Setting->SetDevName(TEXT("FrameRateLimit_Always")); // 设置开发名称
		Setting->SetDisplayName(LOCTEXT("FrameRateLimit_Always_Name", "Frame Rate Limit")); // 设置显示名称
		Setting->SetDescriptionRichText(LOCTEXT("FrameRateLimit_Always_Description", "Frame rate limit sets the highest frame rate that is allowed. Set this lower for a more consistent frame rate or higher for the best experience on faster machines. You may need to disable Vsync to reach high frame rates.")); // 设置描述富文本

		Setting->SetDynamicGetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(GetFrameRateLimit_Always)); // 设置动态获取器
		Setting->SetDynamicSetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(SetFrameRateLimit_Always)); // 设置动态设置器
		Setting->SetDefaultValue(GetDefault<ULyraSettingsLocal>()->GetFrameRateLimit_Always()); // 设置默认值
		Setting->AddEditCondition(MakeShared<FGameSettingEditCondition_FramePacingMode>(ELyraFramePacingMode::DesktopStyle)); // 添加编辑条件

		AddFrameRateOptions(Setting); // 添加帧率选项

		Screen->AddSetting(Setting); // 添加到屏幕设置
	}
}

#undef LOCTEXT_NAMESPACE